package de.cau.apo.samples;

import java.io.FileNotFoundException;
import java.io.IOException;

import de.cau.apo.CommunicationInterface;
import de.cau.apo.problems.unrelatedscheduling.Job;
import de.cau.apo.problems.unrelatedscheduling.Machine;
import de.cau.apo.problems.unrelatedscheduling.USInstance;
import de.cau.apo.problems.unrelatedscheduling.USSolution;

public class UnrelatedSchedulingSample {

	public static void main(String[] args) throws FileNotFoundException, IOException {
		// create instance parse instance file
		USInstance instance = new USInstance();
		instance.parseInstance(CommunicationInterface.getInstance());
		// create solution by assigning every job to the first possible machine
		USSolution solution = new USSolution(instance);
		for (Job job : instance.getJobs()) {
			for (Machine machine : solution.getMachines()) {
				if (job.isAssignableTo(machine)) {
					machine.addJob(job);
					break;
				}
			}
		}
		// publish solution and do debug information output
		if (CommunicationInterface.publishSolution(solution)) {
			System.err.println("Solution is feasible");
		} else {
			System.err.println("Solution is not feasible");
		}
	}

}
